<template>
  <el-alert :title="'当前网站注册用户有 '+userData.length+' 人'" type="success" center show-icon :closable='false'> </el-alert>
  <el-table
    :data="userData"
    empty-text="暂时还没任何用户哦"
    stripe
    border
  >
    <el-table-column
    prop="name"
    label="用户名"
    align="center"
    >
    </el-table-column>
    <el-table-column
      label="用户名"
      align="center"
    >
      <template #default="scope">
        <el-image
          style="width: 100px; height: 100px"  
          :src="baseURL+scope.row.phone" 
          lazy   
        ></el-image>
      </template>
    </el-table-column>
    <el-table-column
      label="注册时间"
      align="center"
    >
      <template #default="scope">
        {{conversionDate(scope.row.date)}}
      </template>
    </el-table-column>
  </el-table>
</template>
 
<script>
export default {
  name: '',
  data(){
    return{
      userData:[]
    }
  },
  methods:{
    // 获取用户信息
    async getUserData(){
      let {data} = await this.$axios.get("/admin/administrators/getUser")
      this.userData = data.data
    },
     // 日期转化
    conversionDate(date){
      let time = new Date(date)
      let y = time.getFullYear()
      let month = time.getMonth()+1<10?"0"+( time.getMonth()+1): time.getMonth()+1
      let day = time.getDate()<10?"0"+time.getDate():time.getDate()
      let h = time.getHours()<10?"0"+time.getHours():time.getHours()
      let f = time.getMinutes()<10?"0"+time.getMinutes():time.getMinutes()
      let s = time.getSeconds()<10?"0"+time.getSeconds():time.getSeconds()
      return `${y}-${month}-${day} ${h}:${f}:${s}`
    },
  },
  created(){
    this.getUserData()
  }
}
</script>

<style scoped lang='less'>
</style>